Broadway: Allow Compilation on Windows/MSVC
authorChun-wei Fan <fanchunwei@src.gnome.org>
Mon, 1 Jul 2013 12:51:03 +0000 (14:51 +0200)
committerAlexander Larsson <alexl@redhat.com>
Mon, 1 Jul 2013 12:51:03 +0000 (14:51 +0200)
-Don't include unistd.h unconditionally as it's not available in Visual
 Studio, but include io.h where necessary.
-Avoid C99isms, and use _chsize_s in place of ftruncate when unistd.h is
 not available (as in the case of Visual Studio)

gdk/broadway/broadway-server.c
gdk/broadway/gdkbroadway-server.c
gdk/broadway/gdkdisplay-broadway.c
gdk/broadway/gdkkeys-broadway.c

index 37135c5ab8542f5afd4125de46943c3696845066..7c3b334c37daacd949459aee74c43b9530af7ec0 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#elif defined (G_OS_WIN32)
+#include <io.h>
+#endif
 #include <crypt.h>
 #ifdef HAVE_SYS_MMAN_H
 #include <sys/mman.h>
@@ -979,7 +983,7 @@ static gchar *
 generate_handshake_response_wsietf_v7 (const gchar *key)
 {
   gsize digest_len = 20;
-  guchar digest[digest_len];
+  guchar digest[20];
   GChecksum *checksum;
 
   checksum = g_checksum_new (G_CHECKSUM_SHA1);
index 27fca43d0e2187ee4cb0d2793239dfcbb27c0329..5017ef27e3658a6bbb818a2d598542dffea171da 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#elif defined (G_OS_WIN32)
+#include <io.h>
+#define ftruncate _chsize_s
+#endif
 #include <sys/types.h>
 #ifdef G_OS_WIN32
 #include <windows.h>
index 70d5edf9020b16cd7f7b261f9588d27784480260..dff7457147e91dbe5fb2ffbfdca3aeec55766d71 100644 (file)
@@ -37,7 +37,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <sys/types.h>
 
 static void   gdk_broadway_display_dispose            (GObject            *object);
index 4c9cc2a93954a2febdbbdf7ca78f0a644f5b27a2..cf3c029af4f8a29ae45bfc9d6261d1bfc9dfb4f1 100644 (file)
@@ -33,7 +33,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <limits.h>
 #include <errno.h>